package com.gitee.jjnnzb.designpatterninspring.common.threadlocal;


import java.util.Objects;

/**
 * 日志信息
 *
 * @author Administrator
 * @since 2020-01-07 09:58
 */
public class LogThreadLocal {
    private LogThreadLocal() {
    }
    
    private static final ThreadLocal<Long> REQUEST_LOG_ENTITY_HOLDER = new ThreadLocal<>();
    
    public static void setThreadLocal(Long startTime) {
        REQUEST_LOG_ENTITY_HOLDER.set(startTime);
    }
    
    public static Long getThreadLocal() {
        Long startTime = REQUEST_LOG_ENTITY_HOLDER.get();
        if (Objects.isNull(startTime)) {
            return 0L;
        }
        return startTime;
    }
    
    public static void remove() {
        REQUEST_LOG_ENTITY_HOLDER.remove();
    }
}
